package com.app.service.impl;

import com.app.mapper.AdvertisementMapper;
import com.app.mapper.AdvertisementSonMapper;
import com.app.model.AdvertisementModel;
import com.app.model.AdvertisementSonModel;
import com.app.service.AdvertisementService;
import com.app.service.AdvertisementSonService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description:广告子图集
 * @Author: N
 * @Date: 2022年11月24日 10点29分
 */
@Service
public class AdvertisementSonServiceImpl implements AdvertisementSonService {
    @Autowired
    AdvertisementSonMapper advertisementSonMapper;

    @Override
    public List<AdvertisementSonModel> getListByFatherId(int fatherId) {
            QueryWrapper<AdvertisementSonModel> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("father_id", fatherId);
            List<AdvertisementSonModel> list = advertisementSonMapper.selectList(queryWrapper);
            if (list==null||list.isEmpty()) {
                return null;
            } else {
                return list;
            }
        }

    @Override
    public int insert(AdvertisementSonModel model) {
        return advertisementSonMapper.insert(model);
    }

    @Override
    public void delete(Integer fatherId) {
        QueryWrapper<AdvertisementSonModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("father_id", fatherId);
        advertisementSonMapper.delete(queryWrapper);
    }
}
